﻿using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Windows.Forms;
using Titan.FIS.Enum;
using Titan.FIS.LMS.Common;
using Titan.FIS.LMS.Helper;
using Titan.FIS.UI;
using Titan.WinFormSys;
using Titan.WinFormSys.Entity;

namespace Titan.FIS.LMS
{
    [Description("化验设备枚举")]
    public enum LaboratoryInstrumentPlus
    {
        [Description("量热仪A")]
        LR_A = 1,
        [Description("量热仪B")]
        LR_B = 2,
        [Description("量热仪C")]
        LR_C = 4,
        [Description("量热仪D")]
        LR_D = 5,
        [Description("定硫仪A")]
        DL_A = 6,
        [Description("定硫仪B")]
        DL_B = 8,
        [Description("定硫仪C")]
        DL_C = 10,
        [Description("定硫仪D")]
        DL_D = 9,
        [Description("水分仪A")]
        SF_A = 12,
        [Description("水分仪B")]
        SF_B = 14,
        [Description("水分仪C")]
        SF_C = 16,
        [Description("工分仪A")]
        GF_A = 18,
        [Description("工分仪B")]
        GF_B = 20,
        [Description("工分仪C")]
        GF_C = 22,
        [Description("工分仪D")]
        GF_D = 19,
        [Description("工分仪E")]
        GF_E = 21,
        [Description("入厂灰熔融A")]
        HRR_A = 24,
        [Description("入厂灰熔融B")]
        HRR_B = 26,
        [Description("入炉灰熔融A")]
        HRR_C = 28,
        [Description("入炉灰熔融B")]
        HRR_D = 30,
        [Description("入炉天平A")]
        TP_A = 32,
        [Description("入炉天平B")]
        TP_B = 34,
        [Description("入厂天平A")]
        TP_C = 36,
        [Description("入厂天平B")]
        TP_D = 38,
        [Description("粘结指数测定仪A")]
        ZJ_A = 40,
        [Description("粘结指数测定仪B")]
        ZJ_B = 42,
        [Description("粘结指数测定仪C")]
        ZJ_C = 41,
        [Description("粘结指数测定仪D")]
        ZJ_D = 43,
        [Description("全自动胶质层测定仪A前")]
        JZ_AQ = 45,
        [Description("全自动胶质层测定仪A后")]
        JZ_AH = 46,
        [Description("全自动胶质层测定仪B前")]
        JZ_BQ = 47,
        [Description("全自动胶质层测定仪B后")]
        JZ_BH = 48,
        [Description("全自动胶质层测定仪C前")]
        JZ_CQ = 49,
        [Description("全自动胶质层测定仪C后")]
        JZ_CH = 50,
        [Description("全自动胶质层测定仪D前")]
        JZ_DQ = 51,
        [Description("全自动胶质层测定仪D后")]
        JZ_DH = 52,
        [Description("全自动胶质层测定仪E前")]
        JZ_EQ = 53,
        [Description("全自动胶质层测定仪E后")]
        JZ_EH = 54,
        [Description("焦炭反应性1#")]
        CRI_A = 56,
        [Description("焦炭反应性2#")]
        CRI_B = 57,
        [Description("焦炭反应性3#")]
        CRI_C = 58,
        [Description("焦炭反应性4#")]
        CRI_D = 59,
        [Description("焦炭反应性5#")]
        CRI_E = 60,
        [Description("焦炭反应性6#")]
        CRI_F = 61,
        [Description("焦炭反应性7#")]
        CRI_G = 62,
        [Description("全自动胶质层测定仪F前")]
        JZ_FQ = 63,
        [Description("全自动胶质层测定仪F后")]
        JZ_FH = 64,
        [Description("未知")]
        Unknown = 99
    }
    /// <summary>
    /// 化验采集结果确认、审核
    /// </summary>
    public partial class FrmResultManage : FrmBase
    {
        /// <summary>
        /// 需化验确认的数据
        /// </summary>
        private DataTable _dtConfirmData;
        /// <summary>
        /// 勾选的行
        /// </summary>
        private readonly IList<UltraGridRow> _listSelectGridRow = new List<UltraGridRow>();
        /// <summary>
        /// 当前激活的行
        /// </summary>
        private UltraGridRow _ugrActiveRow;

        /// <summary>
        /// 当前查询指标类型
        /// </summary>
        private string _strQueryIndexType = string.Empty;

        /// <summary>
        /// 当前化验室
        /// </summary>
        private LaboratoryType _LabType = LaboratoryType.RC;


        /// <summary>
        /// 构造方法
        /// </summary>
        public FrmResultManage()
        {
            InitializeComponent();
            this.ActiveControl = ute_AsTestCode;
            Common.Common.UserInfo = UserInfo;
            foreach (RolePowersEntity power in UserInfo.Powers)
            {
                if (power.NavigateUrl == "Titan.FIS.LMS.FrmResultManage" && power.KeyCode == "Check")
                {
                    ultraTool.Tools["AuditData"].SharedProps.Visible = true;
                    ultraTool.Tools["化验数据状态"].SharedProps.Visible = true;
                    ultraTool.Tools["ControlContainerTool3"].SharedProps.Visible = true;
                    utc_AsTestType.Items.Add("6666", "化验结果数据");
                }
                if (power.NavigateUrl == "Titan.FIS.LMS.FrmResultManage" && power.KeyCode == "Manual")
                {
                    ultraTool.Tools["Manually"].SharedProps.Visible = true;
                }
            }

            ultraTool.Tools["Print"].SharedProps.Visible = false;
            string strLmsLabType = System.Configuration.ConfigurationManager.AppSettings["LMS_LAB"];
            _LabType = LaboratoryType.RC;
        }

        private void utc_AsType_ValueChanged(object sender, EventArgs e)
        {
            ute_AsTestCode.Focus();
            DoQuery();
        }

        private void ute_AsNo_Click(object sender, EventArgs e)
        {
            ute_AsTestCode.Text = "";
        }

        private void rBNormal_CheckedChanged(object sender, EventArgs e)
        {
            if (rBNormal.Checked)
            {
                var strTestCode = ute_AsTestCode.Text;
                try
                {
                    var tmp = int.Parse(strTestCode.ToString());
                    if (tmp <= 0)
                        return;
                    if (strTestCode.Length == 9)
                        rBNormal.Checked = true;
                    else
                        rBNotNormal.Checked = true;
                }
                catch
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"样品编号《{0}》为非常规样！如果是常规样，请检查化验编码是否输入错误，谢谢！", strTestCode));
                    rBNotNormal.Checked = true;
                }
            }
            ute_AsCRC.Text = "";
        }

        private void cBCRC_CheckedChanged(object sender, EventArgs e)
        {
            if (cBCRC.Checked)
            {
                var cType = 0;
                if (rBCheck.Checked)
                    cType = 1;
                var sType = 0;
                if (rBNotNormal.Checked)
                    sType = 1;

                var strAsTestCode = ute_AsTestCode.Text;
                var errMsg = string.Empty;

                var bConfirmed = false;
                errMsg = DataOperate.DataQuery.DoQueryLmsIndexState(strAsTestCode, cType, sType, (int)LaboratoryTestMode.Hand, (int)LaboratoryIndex.CRC, ref bConfirmed);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                    cBCRC.Checked = false;
                    return;
                }
                if (bConfirmed)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"化验编码【{0}】已确认过化验指标【CRC】的平行样化验结果，请勿重复确认！", strAsTestCode));
                    cBCRC.Checked = false;
                    return;
                }
                int iCrc;
                try
                {
                    iCrc = int.Parse(ute_AsCRC.Text);
                    if (iCrc > 8)
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "焦渣特征输入异常，请重新输入！");
                        cBCRC.Checked = false;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "焦渣特征输入异常，请重新输入！" + ex.Message);
                    cBCRC.Checked = false;
                    return;
                }
                if (iCrc == 0)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "请输入焦渣特征！");
                    cBCRC.Checked = false;
                }
            }
        }

        /// <summary>
        /// 数据显示表格点击事件，用于勾选需要操作的行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void utg_Main_Click(object sender, EventArgs e)
        {
            if (utg_Main.ActiveRow != null)
            {
                try
                {
                    utg_Main.ActiveRow.Cells["CHECK"].Value = !(bool)utg_Main.ActiveRow.Cells["CHECK"].Value;
                    if ((bool)utg_Main.ActiveRow.Cells["CHECK"].Value)
                    {
                        _listSelectGridRow.Add(utg_Main.ActiveRow);
                    }
                    else
                    {
                        _listSelectGridRow.Remove(utg_Main.ActiveRow);
                    }
                }
                catch
                {
                    utg_Main.ActiveRow.Cells["CHECK"].Value = true;
                    _listSelectGridRow.Add(utg_Main.ActiveRow);
                }

                ute_AsTestCode.Text = utg_Main.ActiveRow.Cells["TEST_CODE"].Value.ToString();
                _ugrActiveRow = utg_Main.ActiveRow;

            }
        }

        /// <summary>
        /// 按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ultraTool_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
        {
            switch (e.Tool.Key)
            {
                case "CopyCode":
                    DoCopyCode();
                    break;
                case "Query":
                    DoQuery();
                    break;
                case "ConfirmResult":
                    DoConfirmResult();
                    break;
                case "BatchConfirmed":
                    DoBatchConfirm();
                    break;
                case "AuditData":
                    DoAuditData();
                    break;
                case "Print":
                    break;
                case "Manually":
                    DoManuallyInput();
                    break;
            }
        }

        private void DoCopyCode()
        {
            if (!string.IsNullOrEmpty(ute_AsTestCode.Text))
            {
                Clipboard.SetText(ute_AsTestCode.Text);
                FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format("复制化验编码【{0}】成功！", ute_AsTestCode.Text));
            }
            else
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format("化验编码为空，请检查！"));
            }
        }

        /// <summary>
        /// 查询采集结果
        /// </summary>
        private void DoQuery()
        {
            if (string.IsNullOrEmpty(utc_AsTestType.Text))
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "请选择化验指标后在进行查询");
                return;
            }

            _strQueryIndexType = utc_AsTestType.SelectedItem.DataValue.ToString();

            _listSelectGridRow.Clear();
            tabData.Rows.Clear();
            tabDataReport.Rows.Clear();
            utg_Main.DataSource = null;

            var strStartTime = Convert.ToDateTime(ute_Start.Value).ToString("yyyy-MM-dd") + " 00:00:00";
            var strEndTime = Convert.ToDateTime(ute_End.Value).ToString("yyyy-MM-dd") + " 23:59:59";
            var strAsTestCode = ute_AsTestCode.Text;
            var strAsTypeText = utc_AsTestType.SelectedItem.DisplayText;
            var strAsType = _strQueryIndexType;
            var strState = comBoxAuditState.Text;
            DataTable tabSource = null;
            var errMsg = DataOperate.DataQuery.DoQueryLmsResultInfo(_LabType, strStartTime, strEndTime, strAsTestCode, strAsTypeText, strAsType, strState, ref tabSource);
            if (!string.IsNullOrEmpty(errMsg))
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                return;
            }
            try
            {
                //显示查询结果
                if (!string.IsNullOrEmpty(utc_AsTestType.Text))
                {
                    tabSource.Columns.Add("CHECK", typeof(bool));
                    tabSource.Columns["CHECK"].ReadOnly = false;
                    if (strAsTypeText == "化验结果数据")
                    {
                        DataTable tabSourceIndex = null;
                        errMsg = DataOperate.DataQuery.DoQueryReTestIndex("", "1", ref tabSourceIndex);
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                        }

                        Titan.FIS.Data.MergeDataTable.MergeCaption(tabDataReport, ref tabSource);
                        if (_LabType == LaboratoryType.RC)
                        {
                            DisplayLayoutReportRC(tabSource);

                            //UltraGrid红色显示预警
                            Infragistics.Win.Appearance TemperatureAlarm = new Infragistics.Win.Appearance();
                            //TemperatureAlarm.TextHAlign = Infragistics.Win.HAlign.Center;
                            TemperatureAlarm.BackColor = Color.White;
                            TemperatureAlarm.ForeColor = Color.Red;

                            //UltraGrid黄色显示预警
                            Infragistics.Win.Appearance DisNetDiagnosisAlarm = new Infragistics.Win.Appearance();
                            //TemperatureAlarm.TextHAlign = Infragistics.Win.HAlign.Center;
                            DisNetDiagnosisAlarm.BackColor = Color.Yellow;
                            DisNetDiagnosisAlarm.ForeColor = Color.Black;


                            //UltraGrid绿色显示  复检时系统自动复制mad等指标值时标绿 
                            Infragistics.Win.Appearance madAuto = new Infragistics.Win.Appearance();
                            madAuto.BackColor = Color.White;
                            madAuto.ForeColor = Color.Green;

                            for (int i = 0; i < tabSource.Rows.Count; i++)
                            {
                                var tmpRow = tabSource.Rows[i];
                                var index_id = "MT";
                                if (tabSource.Rows[i][index_id].ToString().Contains("_系统"))
                                {
                                    tabSource.Rows[i][index_id] = tabSource.Rows[i][index_id].ToString().Replace("_系统", "");
                                    FormHelper.SetGridCellAppearance(utg_Main, i, index_id, madAuto);
                                }
                                index_id = "MAD";
                                if (tabSource.Rows[i][index_id].ToString().Contains("_系统"))
                                {
                                    tabSource.Rows[i][index_id] = tabSource.Rows[i][index_id].ToString().Replace("_系统", "");
                                    FormHelper.SetGridCellAppearance(utg_Main, i, index_id, madAuto);
                                }
                                index_id = "AAD";
                                if (tabSource.Rows[i][index_id].ToString().Contains("_系统"))
                                {
                                    tabSource.Rows[i][index_id] = tabSource.Rows[i][index_id].ToString().Replace("_系统", "");
                                    FormHelper.SetGridCellAppearance(utg_Main, i, index_id, madAuto);
                                }
                                index_id = "VAD";
                                if (tabSource.Rows[i][index_id].ToString().Contains("_系统"))
                                {
                                    tabSource.Rows[i][index_id] = tabSource.Rows[i][index_id].ToString().Replace("_系统", "");
                                    FormHelper.SetGridCellAppearance(utg_Main, i, index_id, madAuto);
                                }
                                index_id = "STAD";
                                if (tabSource.Rows[i][index_id].ToString().Contains("_系统"))
                                {
                                    tabSource.Rows[i][index_id] = tabSource.Rows[i][index_id].ToString().Replace("_系统", "");
                                    FormHelper.SetGridCellAppearance(utg_Main, i, index_id, madAuto);
                                }
                                index_id = "QBAD";
                                if (tabSource.Rows[i][index_id].ToString().Contains("_系统"))
                                {
                                    tabSource.Rows[i][index_id] = tabSource.Rows[i][index_id].ToString().Replace("_系统", "");
                                    FormHelper.SetGridCellAppearance(utg_Main, i, index_id, madAuto);
                                }

                                if (tmpRow["TEST_STATE"].ToString() == "未审核" && tmpRow["STYPE"].ToString() == "常规样")
                                {
                                    FormHelper.SetGridCellAppearance(utg_Main, i, "TEST_STATE", DisNetDiagnosisAlarm);
                                    //if (tmpRow["BATCH_TYPE"].ToString() == "入厂煤"|| (tmpRow["BATCH_TYPE"].ToString() == "自采煤" && tmpRow["MATERIEL_TYPE_NAME"].ToString() == "火车煤")) //tmpRow["BATCH_TYPE"].ToString() == "入厂煤"
                                    if (tmpRow["BATCH_TYPE"].ToString() == "入厂煤")
                                    {
                                        var dataRows = tabSourceIndex.Select($" MATERIEL_ID = '{tmpRow["MATERIEL_ID"]}'");
                                        for (int j = 0; j < dataRows.Length; j++)
                                        {
                                            try
                                            {
                                                var min = dataRows[j]["VALUE_MIN"].ToString();
                                                var vbase = dataRows[j]["VALUE_BASE"].ToString();
                                                var max = dataRows[j]["VALUE_MAX"].ToString();
                                                var type = dataRows[j]["VALUE_TYPE"].ToString();
                                                var value = tmpRow[dataRows[j]["INDEX_CODE"].ToString()].ToString();
                                                var bNeedReCheck = false;
                                                if (!string.IsNullOrEmpty(value) && value != "0")
                                                {
                                                    if (type == "1")
                                                    {
                                                        try
                                                        {
                                                            bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse(min)) || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(max));
                                                        }
                                                        catch { }
                                                    }
                                                    else if (type == "2")
                                                    {
                                                        try
                                                        {
                                                            if (!string.IsNullOrEmpty(vbase))
                                                            {
                                                                if (vbase.Contains("~"))
                                                                {
                                                                    var vbases = vbase.Split('~');
                                                                    bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse("-" + min.Replace("-", "")) + decimal.Parse(vbases[0])) || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(max) + decimal.Parse(vbases[1]));
                                                                }
                                                                else
                                                                    bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse("-" + min.Replace("-", "")) + decimal.Parse(vbase)) || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(max) + decimal.Parse(vbase));

                                                            }
                                                        }
                                                        catch { }
                                                    }
                                                }
                                                if (bNeedReCheck)
                                                    FormHelper.SetGridCellAppearance(utg_Main, i, dataRows[j]["INDEX_CODE"].ToString(), TemperatureAlarm);
                                            }
                                            catch { }
                                        }
                                    }
                                    else
                                    {
                                        var dataRows = tabSourceIndex.Select($" MATERIEL_NAME = '{tmpRow["MATERIEL_TYPE_NAME"]}' ");
                                        //var dataRows = tabSourceIndex.Select($" MATERIEL_NAME = '{tmpRow["MATERIEL_TYPE_NAME"]}' OR MATERIEL_ID = '{tmpRow["MATERIEL_ID"]}' ");
                                        if (!RowIsNUll(dataRows))
                                           dataRows = tabSourceIndex.Select($" MATERIEL_ID = '{tmpRow["MATERIEL_ID"]}'");
                                        for (int j = 0; j < dataRows.Length; j++)
                                        {
                                            try
                                            {
                                                var min = dataRows[j]["VALUE_MIN"].ToString();
                                                var max = dataRows[j]["VALUE_MAX"].ToString();
                                                var type = dataRows[j]["VALUE_TYPE"].ToString();
                                                var value = tmpRow[dataRows[j]["INDEX_CODE"].ToString()].ToString();
                                                var bNeedReCheck = false;
                                                if (!string.IsNullOrEmpty(value) && value != "0")
                                                {
                                                    if (type == "1")//范围
                                                    {
                                                        try
                                                        {
                                                            bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse(min)) || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(max));
                                                        }
                                                        catch { }
                                                    }
                                                    else if (type == "2")//基值波动
                                                    {
                                                        var dataRowsBase = tabSourceIndex.Select($" MATERIEL_ID = '{tmpRow["MATERIEL_ID"]}' AND INDEX_CODE = '{dataRows[j]["INDEX_CODE"]}'");//获取基值
                                                        if (dataRowsBase.Length > 0)
                                                        {
                                                            var baseType = dataRowsBase[0]["VALUE_TYPE"].ToString();
                                                            if (baseType == "1")
                                                            {
                                                                var vbaseMin = dataRows[0]["VALUE_MIN"].ToString();
                                                                var vbaseMax = dataRows[0]["VALUE_MAX"].ToString();
                                                                try
                                                                {
                                                                    if (!string.IsNullOrEmpty(vbaseMin))
                                                                    {
                                                                        bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse(vbaseMin) - decimal.Parse(min));
                                                                    }
                                                                    if (!string.IsNullOrEmpty(vbaseMax))
                                                                    {
                                                                        bNeedReCheck = bNeedReCheck || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(vbaseMax) + decimal.Parse(max));
                                                                    }
                                                                }
                                                                catch { }
                                                            }
                                                            else if (baseType == "2")
                                                            {
                                                                var vbase = dataRowsBase[0]["VALUE_BASE"].ToString();
                                                                try
                                                                {
                                                                    if (!string.IsNullOrEmpty(vbase))
                                                                    {
                                                                        if (vbase.Contains("~"))
                                                                        {
                                                                            var vbases = vbase.Split('~');
                                                                            bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse("-" + min.Replace("-", "")) + decimal.Parse(vbases[0])) || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(max) + decimal.Parse(vbases[1]));
                                                                        }
                                                                        else
                                                                            bNeedReCheck = (!string.IsNullOrEmpty(min) && decimal.Parse(value) < decimal.Parse("-" + min.Replace("-", "")) + decimal.Parse(vbase)) || (!string.IsNullOrEmpty(max) && decimal.Parse(value) > decimal.Parse(max) + decimal.Parse(vbase));

                                                                    }
                                                                }
                                                                catch { }
                                                            }
                                                        }
                                                    }
                                                }
                                                if (bNeedReCheck)
                                                    FormHelper.SetGridCellAppearance(utg_Main, i, dataRows[j]["INDEX_CODE"].ToString(), TemperatureAlarm);
                                            }
                                            catch { }
                                        }
                                    }
                                }
                            }
                        }
                        else DisplayLayoutReportQT(tabSource);

                        //UltraGrid自适应宽度
                        utg_Main.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
                        //去掉选择行的默认颜色
                        //utg_Main.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;
                        //utg_Main.DisplayLayout.Override.ActiveCellAppearance.Reset();
                        //utg_Main.DisplayLayout.Override.ActiveRowAppearance.Reset();
                    }
                    else
                    {
                        foreach (DataRow dataRow in tabSource.Rows)
                        {
                            //dataRow["INSTRUMENT"] = EnumClass.GetEnumDes((LaboratoryInstrument)int.Parse(dataRow["INSTRUMENT"].ToString()));
                            dataRow["INSTRUMENT"] = EnumClass.GetEnumDes((LaboratoryInstrumentPlus)int.Parse(dataRow["INSTRUMENT"].ToString()));
                        }

                        Titan.FIS.Data.MergeDataTable.MergeCaption(tabData, ref tabSource);
                        DisplayLayoutIndex(tabSource);
                    }
                }
            }
            catch (Exception ex)
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "查询失败，原因：" + ex.Message);
                return;
            }

            FormHelper.ApplicationShow(ricMsg, DisplayType.Process, "查询完成！");

            utg_Main.ActiveRow = null;
            utg_Main.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.SteelBlue;//选中背景
        }

        public bool RowIsNUll(DataRow[] dataRows)
        {
            try
            {
                if (dataRows == null)
                    return false;
                if (dataRows.Length <= 0)
                    return false;
                return true;
            }
            catch
            {
                return false;
            }
        }

        private void DoBatchConfirm()
        {
            ultraTool.Enabled = false;
            try
            {
                if (utc_AsTestType.SelectedItem == null)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先选择化验项目，谢谢！");
                    return;
                }
                if (utc_AsTestType.SelectedItem.DisplayText == "化验结果数据")
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"化验结果数据无需确认，如需审核请点击审核按钮，谢谢！");
                    return;
                }
                var strAsTypeText = utc_AsTestType.SelectedItem.DisplayText;
                var strAsType = utc_AsTestType.SelectedItem.DataValue.ToString();
                var cType = 0; var sType = 0; var strTestCodes = string.Empty;
                if (strAsTypeText == "Y" || strAsTypeText == "X" || strAsTypeText == "CRI" || strAsTypeText == "CSR")
                {
                    if (_listSelectGridRow.Count < 1)
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先选择需要确认的行在点击确认按钮，谢谢！");
                        return;
                    }
                    Dictionary<string, UltraGridRow> dtTestCode = new Dictionary<string, UltraGridRow>();
                    for (int i = _listSelectGridRow.Count - 1; i >= 0; i--)
                    {
                        var drDataRow = _listSelectGridRow[i];
                        var strTestCode = drDataRow.Cells["TEST_CODE"].Value.ToString();
                        var strTestState = drDataRow.Cells["STATUS"].Value.ToString();
                        var bNormal = false;
                        try
                        {
                            var tmp = int.Parse(strTestCode);
                            if (tmp <= 0)
                            {
                                _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行
                                continue;
                            }
                            bNormal = strTestCode.Length == 9;
                        }
                        catch
                        {
                            _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行
                            continue;
                        }
                        if (strTestState != "未使用" || !bNormal)
                        {
                            _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行
                        }
                        else
                        {
                            if (!dtTestCode.ContainsKey(strTestCode))
                            {
                                dtTestCode.Add(strTestCode, _listSelectGridRow[i]);
                                strTestCodes = strTestCodes + "," + strTestCode;
                            }
                            else
                            {
                                _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行
                                _listSelectGridRow.Remove(dtTestCode[strTestCode]);//删除不需要审核的行
                                strTestCodes = strTestCodes.Replace("," + strTestCode, "");
                                dtTestCode.Remove(strTestCode);
                                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, $"化验编码【{strTestCode}】的化验指标【{strAsTypeText}】的结果数据只能选择一条确认，请重新选择！");
                            }
                        }
                    }
                    if (dtTestCode.Count > 0)
                        strTestCodes = strTestCodes.Substring(1);
                    else
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, $"化验指标【{utc_AsTestType.Text}】未选择有效的确认数据，请重新选择！");
                        return;
                    }
                    if (MessageBox.Show(string.Format("是否立即对化验编码【{0}】的化验指标【{1}】的结果数据进行确认?", strTestCodes, utc_AsTestType.Text), "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        return;
                    }
                    strTestCodes = "";
                    for (int i = 0; i < _listSelectGridRow.Count; i++)
                    {
                        var strAsTestCode = _listSelectGridRow[i].Cells["TEST_CODE"].Value.ToString();
                        var strValue = _listSelectGridRow[i].Cells["TEST_VALUE"].Value.ToString();
                        var strID = _listSelectGridRow[i].Cells["COLLECTION_ID"].Value.ToString();

                        var bConfirmed = false;
                        var errMsg = DataOperate.DataQuery.DoQueryLmsIndexState(strAsTestCode, cType, sType, (int)LaboratoryTestMode.Instrument, int.Parse(strAsType), ref bConfirmed);
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                            continue;
                        }
                        if (bConfirmed)
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"化验编码【{0}】已确认过化验指标【{1}】的化验结果，请勿重复确认！", strAsTestCode, utc_AsTestType.Text));
                            continue;
                        }

                        if (DataOperate.DataExecProc.DoInsertConfirmedData(strAsTestCode, int.Parse(strAsType), strValue, (int)_LabType, (int)LaboratoryTestMode.Instrument, cType, sType, ref errMsg))
                        {
                            //将使用状态更新到采集表
                            if (!DataOperate.DataExecProc.DoUpdateCollectionDataState(strID, ref errMsg))
                            {
                                errMsg = $"更新化验编码【{strAsTestCode}】的化验指标【{strAsTypeText}】已使用状态到采集表失败，原因：" + errMsg;
                                continue;
                            }
                            else
                                strTestCodes = strTestCodes + "," + strAsTestCode;
                        }
                        else
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的数据失败,请重试，原因：{2}", strAsTestCode, strAsTypeText, errMsg));
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(strTestCodes))
                    {
                        strTestCodes = strTestCodes.Substring(1);
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的化验结果成功！", strTestCodes, utc_AsTestType.Text));
                    }
                }
                else
                {
                    var strStartTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd") + " 00:00:00";
                    var strEndTime = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
                    DataTable tabSource = null;
                    var errMsg = DataOperate.DataQuery.DoQueryLmsResultInfo(_LabType, strStartTime, strEndTime, "", strAsTypeText, strAsType, "", ref tabSource);
                    if (!string.IsNullOrEmpty(errMsg) || tabSource == null)
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                        return;
                    }
                    Dictionary<string, int> dtTestCode = new Dictionary<string, int>();
                    for (int i = 0; i < tabSource.Rows.Count; i++)
                    {
                        var drDataRow = tabSource.Rows[i];
                        var strTestCode = drDataRow["TEST_CODE"].ToString();
                        var strTestState = drDataRow["STATUS"].ToString();
                        var bNormal = false;
                        try
                        {
                            var tmp = int.Parse(strTestCode);
                            if (tmp <= 0)
                                continue;
                            bNormal = strTestCode.Length == 9;
                        }
                        catch
                        {
                            continue;
                        }
                        if (strTestState == "未使用" && bNormal)
                        {
                            if (!dtTestCode.ContainsKey(strTestCode))
                            {
                                dtTestCode.Add(strTestCode, 1);
                                strTestCodes = strTestCodes + "," + strTestCode;
                            }
                            else
                                dtTestCode[strTestCode]++;
                        }
                    }
                    if (dtTestCode.Count > 0)
                        strTestCodes = strTestCodes.Substring(1);
                    else
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, $"化验指标【{utc_AsTestType.Text}】最近首次常规样化验结果已全部完成确认，无需再次确认");
                        return;
                    }
                    if (MessageBox.Show(string.Format("是否立即对化验编码【{0}】的化验指标【{1}】的平行样数据进行确认?", strTestCodes, utc_AsTestType.Text), "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        return;
                    }
                    strTestCodes = "";
                    foreach (string strAsTestCode in dtTestCode.Keys)
                    {
                        if (dtTestCode[strAsTestCode] < 2)
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, $"化验编码【{dtTestCode[strAsTestCode]}】的化验结果确认需要2条平行样数据，请实验完成后再确认谢谢！");
                            continue;
                        }
                        tabSource = null;
                        errMsg = DataOperate.DataQuery.DoQueryLmsResultInfo(_LabType, "", "", strAsTestCode, strAsTypeText, strAsType, "", ref tabSource);
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                            continue;
                        }
                        _dtConfirmData = tabSource;


                        IList<DataRow> listDataRow = _dtConfirmData.Select(string.Format("STATUS = '{0}'", "未使用"));
                        IList<DataRow> listDataRowVad = new List<DataRow>();
                        if (listDataRow.Count < 2)
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"未找到化验编码【{0}】的化验指标【{1}】的未使用平行样数据,请继续试验", strAsTestCode, utc_AsTestType.Text));
                            continue;
                        }
                        var bConfirmed = false;
                        errMsg = DataOperate.DataQuery.DoQueryLmsIndexState(strAsTestCode, cType, sType, (int)LaboratoryTestMode.Instrument, int.Parse(strAsType), ref bConfirmed);
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                            continue;
                        }
                        if (bConfirmed)
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"化验编码【{0}】已确认过化验指标【{1}】的平行样化验结果，请勿重复确认！", strAsTestCode, utc_AsTestType.Text));
                            continue;
                        }
                        var testSampleType = 0;
                        errMsg = DataOperate.DataQuery.DoQueryTestSampleType(strAsTestCode, ref testSampleType);
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                            return;
                        }
                        if (!CountValue(listDataRow, (LaboratoryIndex)int.Parse(strAsType), cType, sType, 0, testSampleType, ref errMsg))
                        {
                            FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的平行样化验结果失败！,原因：{2}", strAsTestCode, utc_AsTestType.Text, errMsg));
                            continue;
                        }
                        else
                            strTestCodes = strTestCodes + "," + strAsTestCode;
                    }
                    if (!string.IsNullOrEmpty(strTestCodes))
                    {
                        strTestCodes = strTestCodes.Substring(1);
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的平行样化验结果成功！", strTestCodes, utc_AsTestType.Text));
                    }
                }
            }
            catch { }
            finally
            {
                ute_AsTestCode.Text = "";
                DoQuery();
                ultraTool.Enabled = true;
            }
        }
        /// <summary>
        /// 确认化验结果
        /// </summary>
        private void DoConfirmResult()
        {
            if (utc_AsTestType.SelectedItem == null)
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先选择化验项目，谢谢！");
                return;
            }
            if (utc_AsTestType.SelectedItem.DisplayText == "化验结果数据")
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"化验结果数据无需确认，如需审核请点击审核按钮，谢谢！");
                return;
            }
            var strAsTypeText = utc_AsTestType.SelectedItem.DisplayText;
            var strAsType = utc_AsTestType.SelectedItem.DataValue.ToString();
            var strAsTestCode = ute_AsTestCode.Text;

            if (strAsTypeText == "Y" || strAsTypeText == "X")
            {
                if (_listSelectGridRow.Count == 0)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先勾选需要确认的行，谢谢！");
                    return;
                }
                if (_listSelectGridRow.Count > 1)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"只能选中一行数据进行确认，谢谢！");
                    return;
                }
                strAsTestCode = _listSelectGridRow[0].Cells["TEST_CODE"].Value.ToString();
            }
            else
            {
                if (string.IsNullOrEmpty(strAsTestCode))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先输入化验号再点击确认按钮，谢谢！");
                    return;
                }

                DataTable tabSource = null;
                var errMsg = DataOperate.DataQuery.DoQueryLmsResultInfo(_LabType, "", "", strAsTestCode, strAsTypeText, strAsType, "", ref tabSource);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                    return;
                }
                if (tabSource.Rows.Count < 2)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "化验结果确认需要2条平行样数据，请继续试验，谢谢！");
                    return;
                }
                _dtConfirmData = tabSource;
            }

            rBNotNormal.Checked = true;
            try
            {
                //DateTime tmp = DateTime.ParseExact(strAsNo.Substring(0, strAsNo.Length - 3), "yyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                var tmp = int.Parse(strAsTestCode.ToString());
                if (tmp <= 0)
                    return;
                rBNormal.Checked = strAsTestCode.Length == 9;
            }
            catch
            {
                rBNormal.Checked = false;
            }
            rBFirst.Checked = true;
            ute_AsCRC.Text = "0";
            cBCRC.Checked = false;

            panelConfrim.Location = new Point((Width - panelConfrim.Width) / 2, (Height - panelConfrim.Height) / 2 - 164);
            panelConfrim.Visible = true;
            ultraTool.Enabled = false;
        }

        /// <summary>
        /// 确认化验结果取消
        /// </summary>
        private void bn_Back_Click(object sender, EventArgs e)
        {
            panelConfrim.Visible = false;
            ultraTool.Enabled = true;
        }

        /// <summary>
        /// 确认化验结果确认
        /// </summary>
        private void bn_OK_Click(object sender, EventArgs e)
        {
            var cType = 0;
            if (rBCheck.Checked)
                cType = 1;
            if (rBReCheck.Checked)
                cType = 2;
            var sType = 0;
            if (rBNotNormal.Checked)
                sType = 1;

            var strAsTestCode = ute_AsTestCode.Text;
            var errMsg = string.Empty;

            var strAsTypeText = utc_AsTestType.SelectedItem.DisplayText;
            var strAsType = utc_AsTestType.SelectedItem.DataValue.ToString();
            if (strAsTypeText == "Y" || strAsTypeText == "X" || strAsTypeText == "CRI" || strAsTypeText == "CSR")
            {
                strAsTestCode = _listSelectGridRow[0].Cells["TEST_CODE"].Value.ToString();
                var strValue = _listSelectGridRow[0].Cells["TEST_VALUE"].Value.ToString();
                var strID = _listSelectGridRow[0].Cells["COLLECTION_ID"].Value.ToString();
                if (MessageBox.Show(string.Format("是否立即对化验编码【{0}】的化验指标【{1}】的结果数据进行确认?", strAsTestCode, strAsTypeText), "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    var bConfirmed = false;
                    errMsg = DataOperate.DataQuery.DoQueryLmsIndexState(strAsTestCode, cType, sType, (int)LaboratoryTestMode.Instrument, int.Parse(strAsType), ref bConfirmed);
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                        return;
                    }
                    if (bConfirmed)
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"化验编码【{0}】已确认过化验指标【{1}】的化验结果，请勿重复确认！", strAsTestCode, utc_AsTestType.Text));
                        return;
                    }

                    if (DataOperate.DataExecProc.DoInsertConfirmedData(strAsTestCode, int.Parse(strAsType), strValue, (int)_LabType, (int)LaboratoryTestMode.Instrument, cType, sType, ref errMsg))
                    {
                        //将使用状态更新到采集表
                        if (!DataOperate.DataExecProc.DoUpdateCollectionDataState(strID, ref errMsg))
                        {
                            errMsg = $"更新化验编码【{strAsTestCode}】的化验指标【{strAsTypeText}】已使用状态到采集表失败，原因：" + errMsg;
                            return;
                        }

                        FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的数据成功！", strAsTestCode, strAsTypeText));
                        panelConfrim.Visible = false;
                        ultraTool.Enabled = true;

                        DoQuery();
                        return;
                    }
                    else
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的数据失败,请重试，原因：{2}", strAsTestCode, strAsTypeText, errMsg));
                        return;
                    }
                }
                return;
            }

            if (cBCRC.Checked)//CRC直接插入到确认表
            {
                if (MessageBox.Show(string.Format("是否立即对化验编码【{0}】的化验指标【{1}】的平行样数据进行确认?", strAsTestCode, "CRC"), "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    if (DataOperate.DataExecProc.DoInsertConfirmedData(strAsTestCode, (int)LaboratoryIndex.CRC, ute_AsCRC.Text, (int)_LabType, (int)LaboratoryTestMode.Hand, cType, sType, ref errMsg))
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"确认化验编码【{0}】的化验指标【CRC】的数据成功！", strAsTestCode));
                        panelConfrim.Visible = false;
                        ultraTool.Enabled = true;
                        return;
                    }
                    else
                    {
                        FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"确认化验编码【{0}】的化验指标【CRC】的数据失败,请重试，原因：{1}", strAsTestCode, errMsg));
                        return;
                    }
                }
            }

            IList<DataRow> listDataRow = _dtConfirmData.Select(string.Format("STATUS = '{0}'", "未使用"));
            IList<DataRow> listDataRowVad = new List<DataRow>();
            if (listDataRow.Count < 2)
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"未找到化验编码【{0}】的化验指标【{1}】的2条未使用平行样数据,请检查编码(编码前后不能有空格)或者继续试验", strAsTestCode, utc_AsTestType.Text));
                return;
            }
            if (MessageBox.Show(string.Format("是否立即对化验编码【{0}】的化验指标【{1}】的平行样数据进行确认?", strAsTestCode, utc_AsTestType.Text), "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                var bConfirmed = false;
                errMsg = DataOperate.DataQuery.DoQueryLmsIndexState(strAsTestCode, cType, sType, (int)LaboratoryTestMode.Instrument, int.Parse(strAsType), ref bConfirmed);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                    return;
                }
                if (bConfirmed)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"化验编码【{0}】已确认过化验指标【{1}】的平行样化验结果，请勿重复确认！", strAsTestCode, utc_AsTestType.Text));
                    return;
                }


                var testSampleType = 0;
                errMsg = DataOperate.DataQuery.DoQueryTestSampleType(strAsTestCode, ref testSampleType);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                    return;
                }
                panelConfrim.Visible = false;
                ultraTool.Enabled = true;
                if (!CountValue(listDataRow, (LaboratoryIndex)int.Parse(strAsType), cType, sType, 0, testSampleType, ref errMsg))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的平行样化验结果失败！,原因：{2}", strAsTestCode, utc_AsTestType.Text, errMsg));
                    return;
                }

                Log.LogHelper.DoWrite(Log.LogType.Information, $"确认化验编码{strAsTestCode}");
                FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"确认化验编码【{0}】的化验指标【{1}】的平行样化验结果成功！", strAsTestCode, utc_AsTestType.Text));
                DoQuery();
            }
        }

        /// <summary>
        /// 统计所有不为0的元素的个数
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static int ArrayNonzeroCount(decimal[] data)
        {
            return data.Count(t => t != 0);
        }

        /// <summary>
        /// 将旧数组中的不为0的元素拷贝到新的数组之中
        /// </summary>
        /// <param name="src"></param>
        /// <param name="data"></param>
        public static void ArrayNonzeroCopy(decimal[] src, decimal[] data)
        {
            var foot = 0;//表示数组的下标
            foreach (var t in src.Where(t => t != 0))
            {
                data[foot++] = t;//取出里面不为0的内容
            }
        }

        /// <summary>
        /// 计算平行样相关值
        /// </summary>
        /// <returns></returns>
        private bool CountValue(IList<DataRow> listDataRow, LaboratoryIndex index, int iCType, int iSType, decimal madValue, int testSampleType, ref string errMsg)
        {
            var strTestCode = listDataRow[0]["TEST_CODE"].ToString();

            //非CRC需要按规则进行平行样刷选计算
            var dtSeleteID = new Dictionary<string, List<string>>();
            var arrayValue = new decimal[listDataRow.Count];
            var iEffectiveNum = 0;//不为0的未使用值
            for (var j = 0; j < listDataRow.Count; j++)
            {
                try
                {
                    if (!string.IsNullOrEmpty(listDataRow[j]["TEST_VALUE"].ToString()))
                    {
                        arrayValue[j] = decimal.Parse(listDataRow[j]["TEST_VALUE"].ToString());
                        if (arrayValue[j] != 0)
                        {
                            iEffectiveNum++;
                            if (!dtSeleteID.ContainsKey(arrayValue[j].ToString(CultureInfo.InvariantCulture)))//未包含，
                            {
                                var listID = new List<string> { listDataRow[j]["COLLECTION_ID"].ToString() };
                                dtSeleteID.Add(arrayValue[j].ToString(CultureInfo.InvariantCulture), listID);
                            }
                            else//化验的结果数据一样，基本不存在
                            {
                                var listID = dtSeleteID[arrayValue[j].ToString(CultureInfo.InvariantCulture)];
                                listID.Add(listDataRow[j]["COLLECTION_ID"].ToString());
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }
            if (iEffectiveNum < 2)
            {
                errMsg = "有效平行样结果少于2个";
                return false;
            }
            if (iEffectiveNum == 5)
            {
                errMsg = "未使用平行样结果等于5个，根据规则前4个无效，固有效平行样结果少于2个";
                return false;
            }
            if (iEffectiveNum > 5)
            {
                var num = iEffectiveNum % 4;
                if (num == 0)
                    num = 4;
                if (num == 1)
                {
                    errMsg = string.Format("未使用平行样结果等于{0}个，根据规则前4的整数倍个值无效，固有效平行样结果少于2个", iEffectiveNum);
                    return false;
                }
                int residue = 0;
                dtSeleteID.Clear();
                for (int j = listDataRow.Count - 1; j >= 0; j--)
                {
                    if (arrayValue[j] != 0)
                    {
                        residue++;
                        if (!dtSeleteID.ContainsKey(arrayValue[j].ToString(CultureInfo.InvariantCulture)))
                        {
                            var listID = new List<string> { listDataRow[j]["COLLECTION_ID"].ToString() };
                            dtSeleteID.Add(arrayValue[j].ToString(CultureInfo.InvariantCulture), listID);
                        }
                        else
                        {
                            var listID = dtSeleteID[arrayValue[j].ToString(CultureInfo.InvariantCulture)];
                            listID.Add(listDataRow[j]["COLLECTION_ID"].ToString());
                        }
                        if (residue == num)
                        {
                            for (int k = j - 1; k >= 0; k--)
                            {
                                arrayValue[k] = 0;
                            }
                            break;
                        }
                    }
                }
            }

            var arrayEffectiveValue = arrayValue.Where(x => x > 0).ToArray();
            Array.Sort(arrayEffectiveValue);
            Array.Reverse(arrayEffectiveValue);

            var listSelectValue = new List<string>();
            var isFindEffectiveValue = false;
            decimal deEffectiveValue = 0;
            var strEffectiveValue = string.Empty;
            switch (index)
            {
                case LaboratoryIndex.QBAD:
                    isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 0, 0, 120, 120, 120, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 0).ToString("f0");
                    break;
                case LaboratoryIndex.STAD:
                    if (testSampleType == 0)
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 1, 4, (decimal)0.05, (decimal)0.1, (decimal)0.2, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    else
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 1, 4, (decimal)0.05, (decimal)0.05, (decimal)0.05, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 2).ToString("f2");
                    break;
                case LaboratoryIndex.MT:
                    //isFindEffectiveValue = CountValueHelp.CountValueMt(arrayEffectiveValue.Length, 10, 10, (decimal)0.4, (decimal)0.5, (decimal)0.5, arrayEffectiveValueOld, ref listSelectValue, ref deEffectiveValue);
                    if (testSampleType == 0)
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 10, 10, (decimal)0.4, (decimal)0.5, (decimal)0.5, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    else
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 5, (decimal)9.9999, (decimal)0.4, (decimal)0.6, (decimal)0.8, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);

                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 1).ToString("f1");
                    break;
                case LaboratoryIndex.MAD:
                    if (testSampleType == 0)
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 5, 10, (decimal)0.2, (decimal)0.3, (decimal)0.4, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    else
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 5, 10, (decimal)0.2, (decimal)0.2, (decimal)0.2, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 2).ToString("f2");
                    break;
                case LaboratoryIndex.AAD:
                    if (testSampleType == 0)
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 15, 30, (decimal)0.2, (decimal)0.3, (decimal)0.5, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    else
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 15, 30, (decimal)0.2, (decimal)0.2, (decimal)0.2, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 2).ToString("f2");
                    break;
                case LaboratoryIndex.VAD:
                    if (testSampleType == 0)
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 20, 40, (decimal)0.3, (decimal)0.5, (decimal)0.8, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    else
                        isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 20, 40, (decimal)0.3, (decimal)0.3, (decimal)0.3, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = (CountValueHelp.ValueMeliorate46(deEffectiveValue, 2) - madValue).ToString("f2");
                    break;
                case LaboratoryIndex.G:
                    isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 18, 18, 1, 3, 3, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 0).ToString("f0");
                    break;
                case LaboratoryIndex.DT:
                    isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 0, 0, 60, 60, 60, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 0).ToString("f0");
                    break;
                case LaboratoryIndex.ST:
                    isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 0, 0, 40, 40, 40, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 0).ToString("f0");
                    break;
                case LaboratoryIndex.HT:
                    isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 0, 0, 40, 40, 40, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 0).ToString("f0");
                    break;
                case LaboratoryIndex.FT:
                    isFindEffectiveValue = CountValueHelp.CountValue(arrayEffectiveValue.Length, 0, 0, 40, 40, 40, arrayEffectiveValue, ref listSelectValue, ref deEffectiveValue);
                    if (isFindEffectiveValue)
                        strEffectiveValue = CountValueHelp.ValueMeliorate46(deEffectiveValue, 0).ToString("f0");
                    break;
            }

            if (isFindEffectiveValue)
            {
                //将计算出的平行样结果插入到数据确认表
                var strIDs = string.Empty;
                if (DataOperate.DataExecProc.DoInsertConfirmedData(strTestCode, (int)index, strEffectiveValue, (int)_LabType, (int)LaboratoryTestMode.Instrument, iCType, iSType, ref errMsg))
                {
                    foreach (var selectValue in listSelectValue)
                    {
                        if (dtSeleteID.ContainsKey(selectValue)) //包含
                        {
                            List<string> listID = dtSeleteID[selectValue];
                            foreach (var id in listID)
                            {
                                strIDs = strIDs + "," + id;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(strIDs))
                    {
                        errMsg = "参与计算的GUID遗失，请检查是否发生异常";
                        return false;
                    }
                    strIDs = strIDs.Substring(1, strIDs.Length - 1); //去掉开头的，号

                    //将参与计算出的平行样原始数据行更新状态到采集表
                    if (!DataOperate.DataExecProc.DoUpdateCollectionDataState(strIDs, ref errMsg))
                    {
                        errMsg = "更新平行样已使用状态到采集表失败，原因：" + errMsg;
                        return false;
                    }
                }
                else
                    return false;
            }
            else
            {
                errMsg = "没有找到合格的平行样数据，请检查或者重做该项试验！";
                return false;
            }

            return true;
        }

        /// <summary>
        /// 化验数据审核
        /// </summary>
        private void DoAuditData()
        {
            if (utc_AsTestType.SelectedItem == null)
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先选择化验结果数据，谢谢！");
                return;
            }
            if (utc_AsTestType.SelectedItem.DisplayText != "化验结果数据")
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"化验采集数据需化验员先确认，如需确认请点击确认按钮，谢谢！");
                return;
            }
            if (_listSelectGridRow.Count < 1)
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, @"请先选择需要审核的行在点击审核按钮，谢谢！");
                return;
            }
            DataTable tabSourceIndex = null;
            var errMsg = DataOperate.DataQuery.DoQueryReTestIndex("1", "", ref tabSourceIndex);
            if (!string.IsNullOrEmpty(errMsg))
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, errMsg);
                return;
            }

            for (int i = _listSelectGridRow.Count - 1; i >= 0; i--)
            {
                var drDataRow = _listSelectGridRow[i];
                var strTestCode = drDataRow.Cells["TEST_CODE"].Value.ToString();
                var strTestState = drDataRow.Cells["TEST_STATE"].Value.ToString();
                var strCType = drDataRow.Cells["TEST_TYPE"].Value.ToString();
                var strSType = drDataRow.Cells["STYPE"].Value.ToString();

                if (strTestState == "已审核")
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"该行已经审核了,无需审核,已跳过,谢谢！", strTestCode));
                    _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行
                    continue;
                }
                if (strTestState == "无需审核")
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"该行无需审核,已跳过,谢谢！", strTestCode));
                    _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行
                    continue;
                }
                if (strCType == "最终指标值")//非再现性
                {
                    if (strSType == "常规样")
                    {
                        if (_LabType == LaboratoryType.RC)
                        {
                            var noTestIndex = "";
                            if (drDataRow.Cells["BATCH_TYPE"].Value.ToString() == "入厂煤")
                            {
                                var dataRows = tabSourceIndex.Select($" MATERIEL_ID = '{drDataRow.Cells["MATERIEL_ID"].Value}'");
                                for (int j = 0; j < dataRows.Length; j++)
                                {
                                    try
                                    {
                                        var value = drDataRow.Cells[dataRows[j]["INDEX_CODE"].ToString()].Value.ToString();
                                        if (string.IsNullOrEmpty(value))
                                            noTestIndex = noTestIndex + (noTestIndex.Length > 0 ? "," : "") + dataRows[j]["INDEX_DISNAME"].ToString();
                                    }
                                    catch { }

                                }
                            }
                            else
                            {
                                var dataRows = tabSourceIndex.Select($" MATERIEL_NAME = '{drDataRow.Cells["MATERIEL_TYPE_NAME"].Value}'");
                                for (int j = 0; j < dataRows.Length; j++)
                                {
                                    try
                                    {
                                        var value = drDataRow.Cells[dataRows[j]["INDEX_CODE"].ToString()].Value.ToString();
                                        if (string.IsNullOrEmpty(value))
                                            noTestIndex = noTestIndex + (noTestIndex.Length > 0 ? "," : "") + dataRows[j]["INDEX_DISNAME"].ToString();
                                    }
                                    catch { }
                                }
                            }
                            if (!string.IsNullOrEmpty(noTestIndex))
                            {
                                if (MessageBox.Show(string.Format(@"化验号【{0}】还有化验项目【{1}】未确认，是否不需要该化验项结果强制审核？", strTestCode, noTestIndex), "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                {
                                    _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行     
                                }
                            }
                        }
                        else if (_LabType == LaboratoryType.RL)
                        {
                            var strQBAD = drDataRow.Cells["QBAD"].Value.ToString();
                            var strSTAD = drDataRow.Cells["STAD"].Value.ToString();
                            var strMT = drDataRow.Cells["MT"].Value.ToString();
                            var strMAD = drDataRow.Cells["MAD"].Value.ToString();
                            var strAAD = drDataRow.Cells["AAD"].Value.ToString();
                            var strVAD = drDataRow.Cells["VAD"].Value.ToString();
                            //var strCRC = drDataRow.Cells["CRC"].Value.ToString();
                            if (strQBAD == "0" || strSTAD == "0" || strMT == "0" || strMAD == "0" ||
                                strAAD == "0" || strVAD == "0")//|| strCRC == "0")
                            {
                                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"化验号【{0}】还有化验项目未确认，请等所有项目已确认后在进行审核，谢谢！", strTestCode));
                                _listSelectGridRow.Remove(_listSelectGridRow[i]);//删除不需要审核的行                           
                            }
                        }
                    }
                }
            }
            if (_listSelectGridRow.Count < 1)
            {
                DoQuery();
                return;
            }

            rBPass.Checked = true;
            panelAudit.Location = new Point((Width - panelAudit.Width) / 2, (Height - panelAudit.Height) / 2 - 189);
            panelAudit.Visible = true;
            ultraTool.Enabled = false;
        }

        /// <summary>
        /// 审核化验结果通过取消
        /// </summary>
        private void bn_ABack_Click(object sender, EventArgs e)
        {
            panelAudit.Visible = false;
            ultraTool.Enabled = true;
        }

        /// <summary>
        /// 审核化验结果通过确认
        /// </summary>
        private void bn_AOK_Click(object sender, EventArgs e)
        {
            var errMsg = string.Empty;
            //批量审核通过
            foreach (var drDataRow in _listSelectGridRow)
            {
                var strTestCode = drDataRow.Cells["TEST_CODE"].Value.ToString();
                var strUpdateTime = drDataRow.Cells["UPDATE_TIME"].Value.ToString();
                var strCType = drDataRow.Cells["TEST_TYPE"].Value.ToString();

                if (strCType == "最终指标值")//首次化验审核
                {
                    if (drDataRow.Cells["STYPE"].Value.ToString() == "常规样")//常规样审核
                    {
                        if (_LabType == LaboratoryType.RC)
                        {
                            var BusinessType = Enum.BusinessType.ExaminationRC;
                            if (!DataOperate.DataExecProc.DoInsertAutiditAssay(BusinessType, strTestCode, ref errMsg))
                            {
                                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"提交化验编号【{0}】的审批流程时失败，原因：{1}", strTestCode, errMsg));
                                return;
                            }
                        }
                    }
                }
                //更新确认表状态为已审核
                if (!DataOperate.DataExecProc.DoUpdateConfirmedDataState(strTestCode, strUpdateTime, ref errMsg))
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"更新化验编号【{0}】的审核状态时失败，原因：{1}", strTestCode, errMsg));
                    return;
                }
                FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"审核化验编号【{0}】的化验结果通过成功", strTestCode));
            }

            panelAudit.Visible = false;
            ultraTool.Enabled = true;

            DoQuery();
        }

        /// <summary>
        /// 审核不通过选择框值更改事件
        /// </summary>
        private void cBNPass_CheckedChanged(object sender, EventArgs e)
        {
            if (rBNotPass.Checked)
            {
                if (_listSelectGridRow.Count > 1)
                {
                    FormHelper.ApplicationShow(ricMsg, DisplayType.Run, @"注意！不能批量审核化验结果为【不通过】，请选择一行后再进行审核操作，谢谢");
                    return;
                }

                cBNQbad.Checked = false;
                cBNStad.Checked = false;
                cBNMt.Checked = false;
                cBNMad.Checked = false;
                cBNAad.Checked = false;
                cBNVad.Checked = false;

                cBNDT.Checked = false;
                cBNST.Checked = false;
                cBNHT.Checked = false;
                cBNFT.Checked = false;

                cBNG.Checked = false;
                cBNY.Checked = false;
                cBNX.Checked = false;
                cBNa.Checked = false;
                cBNb.Checked = false;
                cBNCRI.Checked = false;
                cBNCSR.Checked = false;
                cBNSmall.Checked = false;
                cBNM40.Checked = false;
                cBNM10.Checked = false;
                cBNJTSmall.Checked = false;

                panelAudit.Visible = false;
                panelNAudit.Location = new Point((Width - panelNAudit.Width) / 2, (Height - panelNAudit.Height) / 2 - 143);
                panelNAudit.Visible = true;
            }
        }

        /// <summary>
        /// 审核化验结果不通过取消
        /// </summary>
        private void bn_NABack_Click(object sender, EventArgs e)
        {
            rBPass.Checked = true;
            panelNAudit.Visible = false;
            panelAudit.Visible = true;
        }

        /// <summary>
        /// 审核化验结果不通过确认
        /// </summary>
        private void bn_NAOK_Click(object sender, EventArgs e)
        {
            var strIndexs = string.Empty;
            var strIndexsDesc = string.Empty;
            if (cBNQbad.Checked)
            {
                strIndexs = strIndexs + "1016,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1016")) + ",";
            }
            if (cBNStad.Checked)
            {
                strIndexs = strIndexs + "1012,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1012")) + ",";
            }
            if (cBNMt.Checked)
            {
                strIndexs = strIndexs + "1001,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1001")) + ",";
            }
            if (cBNMad.Checked)
            {
                strIndexs = strIndexs + "1002,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1002")) + ",";
            }
            if (cBNAad.Checked)
            {
                strIndexs = strIndexs + "1003,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1003")) + ",";
            }
            if (cBNVad.Checked)
            {
                strIndexs = strIndexs + "1006,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1006")) + ",";
            }


            if (cBNG.Checked)
            {
                strIndexs = strIndexs + "1027,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1027")) + ",";
            }
            if (cBNY.Checked)
            {
                strIndexs = strIndexs + "1028,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1028")) + ",";
            }
            if (cBNX.Checked)
            {
                strIndexs = strIndexs + "1029,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1029")) + ",";
            }
            if (cBNa.Checked)
            {
                strIndexs = strIndexs + "1030,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1030")) + ",";
            }
            if (cBNb.Checked)
            {
                strIndexs = strIndexs + "1031,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1031")) + ",";
            }
            if (cBNCRI.Checked)
            {
                strIndexs = strIndexs + "1032,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1032")) + ",";
            }
            if (cBNCSR.Checked)
            {
                strIndexs = strIndexs + "1033,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1033")) + ",";
            }
            if (cBNSmall.Checked)
            {
                strIndexs = strIndexs + "1034,1035,1036,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1034")) + ",";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1035")) + ",";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1036")) + ",";
            }
            if (cBNTOD.Checked)
            {
                strIndexs = strIndexs + "1046,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1046")) + ",";
            }
            if (cBNM40.Checked)
            {
                strIndexs = strIndexs + "1037,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1037")) + ",";
            }
            if (cBNM10.Checked)
            {
                strIndexs = strIndexs + "1038,";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1038")) + ",";
            }
            if (cBNJTSmall.Checked)
            {
                strIndexs = strIndexs + "1039,1040,1041,1042,1043";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1039")) + ",";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1040")) + ",";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1041")) + ",";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1042")) + ",";
                strIndexsDesc = strIndexsDesc + EnumClass.GetEnumDes((LaboratoryIndex)int.Parse("1043")) + ",";
            }
            if (string.IsNullOrEmpty(strIndexs))
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, "请先选择不通过的选项在点击确认按钮，谢谢！");
                return;
            }
            strIndexs = strIndexs.Substring(0, strIndexs.Length - 1);//去掉末尾的，号
            strIndexsDesc = strIndexsDesc.Substring(0, strIndexsDesc.Length - 1);//去掉末尾的，号

            var strTestCode = _listSelectGridRow[0].Cells["TEST_CODE"].Value.ToString();
            var strUpdateTime = _listSelectGridRow[0].Cells["UPDATE_TIME"].Value.ToString();

            var errMsg = string.Empty;
            if (!DataOperate.DataExecProc.DoDeleteConfirmedData(strTestCode, strIndexs, strUpdateTime, ref errMsg))
            {
                FormHelper.ApplicationShow(ricMsg, DisplayType.Error, string.Format(@"审核化验编号【{0}】的【{1}】化验结果不通过时失败，原因：{2}", strTestCode,
                   strIndexsDesc, errMsg));

                panelNAudit.Visible = false;
                ultraTool.Enabled = true;
                DoQuery();
                return;
            }
            FormHelper.ApplicationShow(ricMsg, DisplayType.Run, string.Format(@"审核化验编号【{0}】的【{1}】化验结果不通过成功，谢谢！", strTestCode,
                strIndexsDesc));

            panelNAudit.Visible = false;
            ultraTool.Enabled = true;

            DoQuery();
        }
        /// <summary>
        /// 手动录入化验结果
        /// </summary>
        private void DoManuallyInput()
        {
            string strTestCode = string.Empty;
            if (_ugrActiveRow != null && _ugrActiveRow.Cells.Count > 0)
            {
                strTestCode = _ugrActiveRow.Cells["TEST_CODE"].Value.ToString();
            }

            FrmManuallyInput obj = new FrmManuallyInput(strTestCode, _LabType);
            obj.ShowDialog();
            DoQuery();
        }

        /// <summary>
        /// 指标数据查询结果表格窗体布局
        /// </summary>
        /// <param name="_tabSource"></param>
        private void DisplayLayoutIndex(DataTable _tabSource)
        {
            Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand1 = new Infragistics.Win.UltraWinGrid.UltraGridBand("tabData", -1);
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn1 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CHECK");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn2 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_CODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn3 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STATUS");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn4 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("INSTRUMENT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn5 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AUTO_NO");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn6 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_VALUE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn7 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("COLLECTION_TIME");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn8 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("COLLECTION_ID");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn9 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_SAMPLEWEIGHT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn10 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_TIME");
            ultraGridColumn1.Header.VisiblePosition = 0;
            ultraGridColumn2.Header.VisiblePosition = 2;
            ultraGridColumn3.Header.VisiblePosition = 1;
            ultraGridColumn4.Header.VisiblePosition = 3;
            ultraGridColumn5.Header.VisiblePosition = 4;
            ultraGridColumn6.Header.VisiblePosition = 6;
            ultraGridColumn7.Header.VisiblePosition = 8;
            ultraGridColumn7.Width = 200;
            ultraGridColumn8.Header.VisiblePosition = 9;
            ultraGridColumn8.Hidden = true;
            ultraGridColumn9.Header.VisiblePosition = 5;
            ultraGridColumn10.Header.VisiblePosition = 7;
            ultraGridColumn10.Width = 199;
            ultraGridBand1.Columns.AddRange(new object[] {
            ultraGridColumn1,
            ultraGridColumn2,
            ultraGridColumn3,
            ultraGridColumn4,
            ultraGridColumn5,
            ultraGridColumn6,
            ultraGridColumn7,
            ultraGridColumn8,
            ultraGridColumn9,
            ultraGridColumn10});
            utg_Main.DisplayLayout.BandsSerializer.Add(ultraGridBand1);
            utg_Main.DataSource = _tabSource;
        }
        /// <summary>
        /// 煤质分析报告数据查询结果表格窗体布局
        /// </summary>
        /// <param name="_tabSource"></param>
        private void DisplayLayoutReportQT(DataTable _tabSource)
        {
            Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand1 = new Infragistics.Win.UltraWinGrid.UltraGridBand("tabDataReport", -1);
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn1 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_CODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn2 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VAR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn3 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn4 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn5 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AAR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn6 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn7 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QNETAR_KJ");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn8 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QNETAR_KCAL");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn9 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CRC");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn10 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CONFRIMMAN");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn11 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("UPDATE_TIME");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn12 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CHECK");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn13 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn14 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn15 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn16 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QGRAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn17 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_TYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn18 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn19 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn20 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QGRD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn21 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VDAF");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn22 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("FCAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn23 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STAR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn24 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("HAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn25 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QBAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn26 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_STATE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn27 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_MODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn28 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn29 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("G");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn30 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("Y");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn31 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("X");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn32 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("A");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn33 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QBD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn34 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("B");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn35 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CRI");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn36 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CSR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn37 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("SMALL");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn38 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MEDIUM");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn39 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("LARGE");
            ultraGridColumn1.Header.VisiblePosition = 4;
            ultraGridColumn2.Header.VisiblePosition = 26;
            ultraGridColumn3.Header.VisiblePosition = 6;
            ultraGridColumn4.Header.VisiblePosition = 5;
            ultraGridColumn5.Header.VisiblePosition = 25;
            ultraGridColumn6.Header.VisiblePosition = 23;
            ultraGridColumn7.Header.VisiblePosition = 34;
            ultraGridColumn8.Header.VisiblePosition = 35;
            ultraGridColumn9.Header.VisiblePosition = 30;
            ultraGridColumn9.Hidden = true;
            ultraGridColumn10.Header.VisiblePosition = 37;
            ultraGridColumn11.Header.VisiblePosition = 38;
            ultraGridColumn12.Header.VisiblePosition = 0;
            ultraGridColumn13.Header.VisiblePosition = 7;
            ultraGridColumn14.Header.VisiblePosition = 8;
            ultraGridColumn15.Header.VisiblePosition = 9;
            ultraGridColumn16.Header.VisiblePosition = 32;
            ultraGridColumn17.Header.VisiblePosition = 3;
            ultraGridColumn18.Header.VisiblePosition = 21;
            ultraGridColumn19.Header.VisiblePosition = 28;
            ultraGridColumn20.Header.VisiblePosition = 33;
            ultraGridColumn21.Header.VisiblePosition = 22;
            ultraGridColumn22.Header.VisiblePosition = 24;
            ultraGridColumn23.Header.VisiblePosition = 27;
            ultraGridColumn24.Header.VisiblePosition = 29;
            ultraGridColumn25.Header.VisiblePosition = 10;
            ultraGridColumn26.Header.VisiblePosition = 1;
            ultraGridColumn27.Header.VisiblePosition = 36;
            ultraGridColumn28.Header.VisiblePosition = 2;
            ultraGridColumn29.Header.VisiblePosition = 11;
            ultraGridColumn30.Header.VisiblePosition = 12;
            ultraGridColumn31.Header.VisiblePosition = 13;
            ultraGridColumn32.Header.VisiblePosition = 14;
            ultraGridColumn33.Header.VisiblePosition = 31;
            ultraGridColumn34.Header.VisiblePosition = 15;
            ultraGridColumn35.Header.VisiblePosition = 16;
            ultraGridColumn36.Header.VisiblePosition = 17;
            ultraGridColumn37.Header.VisiblePosition = 18;
            ultraGridColumn38.Header.VisiblePosition = 19;
            ultraGridColumn39.Header.VisiblePosition = 20;
            ultraGridBand1.Columns.AddRange(new object[] {
            ultraGridColumn1,
            ultraGridColumn2,
            ultraGridColumn3,
            ultraGridColumn4,
            ultraGridColumn5,
            ultraGridColumn6,
            ultraGridColumn7,
            ultraGridColumn8,
            ultraGridColumn9,
            ultraGridColumn10,
            ultraGridColumn11,
            ultraGridColumn12,
            ultraGridColumn13,
            ultraGridColumn14,
            ultraGridColumn15,
            ultraGridColumn16,
            ultraGridColumn17,
            ultraGridColumn18,
            ultraGridColumn19,
            ultraGridColumn20,
            ultraGridColumn21,
            ultraGridColumn22,
            ultraGridColumn23,
            ultraGridColumn24,
            ultraGridColumn25,
            ultraGridColumn26,
            ultraGridColumn27,
            ultraGridColumn28,
            ultraGridColumn29,
            ultraGridColumn30,
            ultraGridColumn31,
            ultraGridColumn32,
            ultraGridColumn33,
            ultraGridColumn34,
            ultraGridColumn35,
            ultraGridColumn36,
            ultraGridColumn37,
            ultraGridColumn38,
            ultraGridColumn39});
            this.utg_Main.DisplayLayout.BandsSerializer.Add(ultraGridBand1);
            utg_Main.DataSource = _tabSource;
        }
        /// <summary>
        /// 煤质分析报告数据查询结果表格窗体布局
        /// </summary>
        /// <param name="_tabSource"></param>
        private void DisplayLayoutReportRC(DataTable _tabSource)
        {
            Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand1 = new Infragistics.Win.UltraWinGrid.UltraGridBand("tabDataReport", -1);
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn1 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_CODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn2 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VAR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn3 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn4 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn5 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AAR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn6 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn7 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QNETAR_KJ");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn8 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QNETAR_KCAL");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn9 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CRC");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn10 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CONFRIMMAN");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn11 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("UPDATE_TIME");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn12 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CHECK");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn13 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn14 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn15 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn16 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QGRAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn17 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_TYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn18 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn19 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn20 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QGRD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn21 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("VDAF");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn22 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("FCAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn23 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STAR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn24 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("HAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn25 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QBAD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn26 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_STATE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn27 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_MODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn28 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn29 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("G");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn30 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("Y");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn31 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("X");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn32 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("A");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn33 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("QBD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn34 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("B");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn35 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CRI");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn36 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CSR");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn37 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("SMALL");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn38 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MEDIUM");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn39 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("LARGE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn40 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("BATCH_TYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn41 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MATERIEL_TYPE_NAME");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn42 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MATERIEL_ID");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn43 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TOD");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn44 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("M40");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn45 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("M10");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn46 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("JTXXLARGE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn47 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("JTXLARGE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn48 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("JTLARGE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn49 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("JTMEDIUM");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn50 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("JTSMALL");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn51 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("RMAX");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn52 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("MF");

            //wuyou bengin
            //<0.05mm 筛分粒度
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn58 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("SMEDIUN");
            //wuyou end

            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn54 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AUDIT_STATE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn57 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("AUDIT_REMARK");
            ultraGridColumn1.Header.VisiblePosition = 6;
            ultraGridColumn2.Header.VisiblePosition = 14;
            ultraGridColumn2.Hidden = true;
            ultraGridColumn3.Header.VisiblePosition = 8;
            ultraGridColumn4.Header.VisiblePosition = 7;
            ultraGridColumn5.Header.VisiblePosition = 11;
            ultraGridColumn5.Hidden = true;
            ultraGridColumn6.Header.VisiblePosition = 18;
            ultraGridColumn7.Header.VisiblePosition = 27;
            ultraGridColumn7.Hidden = true;
            ultraGridColumn8.Header.VisiblePosition = 26;
            ultraGridColumn9.Header.VisiblePosition = 21;
            ultraGridColumn9.Hidden = true;
            ultraGridColumn10.Header.VisiblePosition = 49;
            ultraGridColumn11.Header.VisiblePosition = 50;
            ultraGridColumn12.Header.VisiblePosition = 0;
            ultraGridColumn13.Header.VisiblePosition = 9;
            ultraGridColumn14.Header.VisiblePosition = 12;
            ultraGridColumn15.Header.VisiblePosition = 17;
            ultraGridColumn16.Header.VisiblePosition = 24;
            ultraGridColumn16.Hidden = true;
            ultraGridColumn17.Header.VisiblePosition = 5;
            ultraGridColumn18.Header.VisiblePosition = 10;
            ultraGridColumn19.Header.VisiblePosition = 13;
            ultraGridColumn19.Hidden = true;
            ultraGridColumn20.Header.VisiblePosition = 25;
            ultraGridColumn20.Hidden = true;
            ultraGridColumn21.Header.VisiblePosition = 15;
            ultraGridColumn22.Header.VisiblePosition = 16;
            ultraGridColumn22.Hidden = true;
            ultraGridColumn23.Header.VisiblePosition = 19;
            ultraGridColumn23.Hidden = true;
            ultraGridColumn24.Header.VisiblePosition = 20;
            ultraGridColumn24.Hidden = true;
            ultraGridColumn25.Header.VisiblePosition = 22;
            ultraGridColumn26.Header.VisiblePosition = 1;
            ultraGridColumn27.Header.VisiblePosition = 48;
            ultraGridColumn28.Header.VisiblePosition = 4;
            ultraGridColumn29.Header.VisiblePosition = 28;
            ultraGridColumn30.Header.VisiblePosition = 29;
            ultraGridColumn31.Header.VisiblePosition = 30;
            ultraGridColumn32.Header.VisiblePosition = 31;
            ultraGridColumn33.Header.VisiblePosition = 23;
            ultraGridColumn33.Hidden = true;
            ultraGridColumn34.Header.VisiblePosition = 32;
            ultraGridColumn35.Header.VisiblePosition = 39;
            ultraGridColumn36.Header.VisiblePosition = 40;
            ultraGridColumn37.Header.VisiblePosition = 36;
            ultraGridColumn38.Header.VisiblePosition = 37;
            ultraGridColumn39.Header.VisiblePosition = 38;
            ultraGridColumn40.Header.VisiblePosition = 51;
            ultraGridColumn40.Hidden = true;
            ultraGridColumn41.Header.VisiblePosition = 52;
            ultraGridColumn41.Hidden = true;
            ultraGridColumn42.Header.VisiblePosition = 53;
            ultraGridColumn42.Hidden = true;
            ultraGridColumn43.Header.VisiblePosition = 33;
            ultraGridColumn44.Header.VisiblePosition = 41;
            ultraGridColumn45.Header.VisiblePosition = 42;
            ultraGridColumn46.Header.VisiblePosition = 43;
            ultraGridColumn47.Header.VisiblePosition = 44;
            ultraGridColumn48.Header.VisiblePosition = 45;
            ultraGridColumn49.Header.VisiblePosition = 46;
            ultraGridColumn50.Header.VisiblePosition = 47;
            ultraGridColumn51.Header.VisiblePosition = 34;
            ultraGridColumn52.Header.VisiblePosition = 35;
            ultraGridColumn54.Header.VisiblePosition = 2;
            ultraGridColumn57.Header.VisiblePosition = 3;
            ultraGridColumn58.Header.VisiblePosition = 27;//
            ultraGridBand1.Columns.AddRange(new object[] {
            ultraGridColumn1,
            ultraGridColumn2,
            ultraGridColumn3,
            ultraGridColumn4,
            ultraGridColumn5,
            ultraGridColumn6,
            ultraGridColumn7,
            ultraGridColumn8,
            ultraGridColumn9,
            ultraGridColumn10,
            ultraGridColumn11,
            ultraGridColumn12,
            ultraGridColumn13,
            ultraGridColumn14,
            ultraGridColumn15,
            ultraGridColumn16,
            ultraGridColumn17,
            ultraGridColumn18,
            ultraGridColumn19,
            ultraGridColumn20,
            ultraGridColumn21,
            ultraGridColumn22,
            ultraGridColumn23,
            ultraGridColumn24,
            ultraGridColumn25,
            ultraGridColumn26,
            ultraGridColumn27,
            ultraGridColumn28,
            ultraGridColumn29,
            ultraGridColumn30,
            ultraGridColumn31,
            ultraGridColumn32,
            ultraGridColumn33,
            ultraGridColumn34,
            ultraGridColumn35,
            ultraGridColumn36,
            ultraGridColumn37,
            ultraGridColumn38,
            ultraGridColumn39,
            ultraGridColumn40,
            ultraGridColumn41,
            ultraGridColumn42,
            ultraGridColumn43,
            ultraGridColumn44,
            ultraGridColumn45,
            ultraGridColumn46,
            ultraGridColumn47,
            ultraGridColumn48,
            ultraGridColumn49,
            ultraGridColumn50,
            ultraGridColumn58,
            ultraGridColumn51,
            ultraGridColumn52,
            ultraGridColumn54,
            ultraGridColumn57});
            this.utg_Main.DisplayLayout.BandsSerializer.Add(ultraGridBand1);
            utg_Main.DataSource = _tabSource;


        }

        /// <summary>
        /// 煤质分析报告数据查询结果表格窗体布局
        /// </summary>
        /// <param name="_tabSource"></param>
        private void DisplayLayoutReportHRR(DataTable _tabSource)
        {
            Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand1 = new Infragistics.Win.UltraWinGrid.UltraGridBand("tabDataReport", -1);
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn68 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("CHECK");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn54 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_CODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn100 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("DT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn101 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("ST");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn102 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("HT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn103 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("FT");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn73 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_TYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn82 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_STATE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn83 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("TEST_MODE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn84 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("STYPE");
            Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn67 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("UPDATE_TIME");
            ultraGridColumn68.Header.VisiblePosition = 0;
            ultraGridColumn54.Header.VisiblePosition = 1;
            ultraGridColumn73.Header.VisiblePosition = 2;
            ultraGridColumn84.Header.VisiblePosition = 3;
            ultraGridColumn83.Header.VisiblePosition = 4;
            ultraGridColumn82.Header.VisiblePosition = 5;
            ultraGridColumn100.Header.VisiblePosition = 6;
            ultraGridColumn101.Header.VisiblePosition = 7;
            ultraGridColumn102.Header.VisiblePosition = 8;
            ultraGridColumn103.Header.VisiblePosition = 9;
            ultraGridColumn67.Header.VisiblePosition = 10;
            ultraGridColumn67.Width = 200;
            ultraGridBand1.Columns.AddRange(new object[] {
            ultraGridColumn54,
            ultraGridColumn68,
            ultraGridColumn73,
            ultraGridColumn67,
            ultraGridColumn100,
            ultraGridColumn101,
            ultraGridColumn102,
            ultraGridColumn103,
            ultraGridColumn82,
            ultraGridColumn83,
            ultraGridColumn84});
            utg_Main.DisplayLayout.BandsSerializer.Add(ultraGridBand1);
            utg_Main.DataSource = _tabSource;
        }

        private void utg_Main_InitializeLayout(object sender, InitializeLayoutEventArgs e)
        {
            e.Layout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.None;
            utg_Main.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.SteelBlue;//选中背景
            utg_Main.DisplayLayout.Bands[0].Columns[0].Header.Fixed = true;
        }

        private void FrmResultManage_Load(object sender, EventArgs e)
        {
            utg_Main.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.SteelBlue;//选中背景
        }
    }
}
